#!/usr/bin/python
# -*- coding: UTF-8 -*-

import pandas as pd

def show(df):
	print("-- DataFrame 全表")
	print(df)
	print("--")
	print("-- 字段")
	print(df.columns)
	print("--")


def clear_cli(df):
	cc = []
	ck = []
	for column in df.columns:
		if "c" not in df.at[0, column]:
			cc.append(column)
			continue
		if "k" in df.at[0, column]:
			ck.append(column)

	df = df.drop(cc, axis=1).drop([0,1]).infer_objects()
	df = df.set_index(df.columns[0], drop=False)

	for i in df.index:
		for k in ck:
			df.at[i, k] = eval(df.at[i, k])

	return df


def clear_srv(df):
	cc = []
	ck = []
	for column in df.columns:
		if "s" not in df.at[0, column]:
			cc.append(column)
			continue
		if "k" in df.at[0, column]:
			ck.append(column)

	df = df.drop(cc, axis=1).drop([0,1]).infer_objects()
	df = df.set_index(df.columns[0], drop=False)

	for i in df.index:
		for k in ck:
			df.at[i, k] = "##" + df.at[i, k]

	return df


def name(path):
	return path.split("/")[-1].split(".")[0]


if __name__ == '__main__':
	print("测试输出")
	print("------------------------------------------------")
	f = "./../excel/example.xlsx"
	base = pd.read_excel(f)
	show(base)
	show(clear_cli(base))
	show(clear_srv(base))
	print(f + " --> " + name(f))



